<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>试卷答题</title>
		<link rel="shortcut icon" href="img/logo.png" />
		<link rel="stylesheet" href="layui/css/layui%20-%20副本.css" media="all">
		<style type="text/css">
			/* 	.a1{
		background-color: antiquewhite;
		width: 100%;
		height: 7%;
		position:fixed; z-index:100; top:0;
		margin-left:-10px;
		
	}
	.a11{
		float: ;
		width: 5%;
		height: 4%;
		background-color: aqua;
		 z-index:999;
	} */
			/* 导航栏 */
			.div1 {
				width: 100%;
				height: 2rem;
				background: #FFF6F6;
				float: left;
				position: fixed;
				top: 0;
				margin-left: -0.625rem;
			}

			/* 导航栏里面的小方框 */
			.div2 {
				width: 1.5rem;
				height: 1.5rem;
				background: #F4F4F5;
				position: fixed;
				top: 0.5%;
				border-radius: 7px;
			}

			/* 导航栏右边时间 */
			.div22 {
				position: absolute;
				margin-top: 5px;
				margin-left: 92%;
			}

			/* 试卷名字 */

			.div3 {
				text-align: center;
			}

			/* 单选题框 */
			.div4 {
				background-color: #FFffff;
				width: 80%;
				height: auto;
				margin-left: 10rem;
				box-shadow: 0 0 10px #EBEEF5;

			}

			/* 多选题框 */
			.div5 {
				background-color: #FFffff;
				width: 80%;
				height: auto;
				margin-left: 10rem;
				box-shadow: 0 0 10px #EBEEF5;
			}
			.div6{
				
				background-color: #FFffff;
				width: 80%;
				height: auto;
				margin-left: 10rem;
				box-shadow: 0 0 10px #EBEEF5;
			}

			#a {
				margin-left: 44%;
			}

			#a1 {
				margin-left: 30%;
			}

			#aa {
				margin-left: 3rem;
			}

			/* 多选题题目 */
			#aaa {
				margin-top: 10px;
				margin-left: 10rem;
			}

			/* 单选题题目 */
			#aaaa {
				margin-left: 10rem;
			}
			/* 简单题的输入框 */
			.t_area{
			width:300px;
			overflow-y:visible
			}
			
			
		</style>
		<script>
		function insert() {
		            $("#guo").append("<img src='qqface/2.gif' />");
		        }
				</script>
	</head>

	<body>
		<!-- 	<div class="a1"></div>
		<div class="a11"></div> -->
		<div class="div1"></div>

		<div class="div22">
			<h7>剩余时间:&nbsp;&nbsp;</h7>
			<h7 id="shijian"></h7>
		</div>

		<!-- <div class="div2">
			<h7 id="a1">1</h7>
		</div> --><br /> <br /> <br />

		<div class="div3">
			<h1>智能训练试卷-1753</h1>


		</div>
		<h7 id="a">试卷得分: </h7>
		<h7 id="aa">试卷耗时: </h7>
		<h3 id="aaa">单选题</h3>
		
		<form action="" method="get">
			<div class="div4">
				<br />

				<table id="table">

				</table>


			</div>
		<h3 id="aaaa">多选题</h3>
					<div class="div5">
						<br />
						<table id="table1">
		
						</table>
					</div>
		
					<h3 id="aaaa">简答题</h3>
		
					<div class="div6">
						<br />
						<table id="table3">
						<!-- 	<h4 style="margin-left: 1.6rem;">1.</h4>
							<h4 style="margin-left: 3rem; margin-top: -1.1rem;">题目</h4>
						<textarea class="t_area" style="width: 100%;"></textarea> -->
					
					</table>
					</div>


		
		<input type="button" onclick="sub()"value="提交"  style="margin-left: 45%; margin-top: 1.875rem; background-color: #409EFF; 
				width: 50px; height: 30px; border:none; border-radius:7px;"/>
		<input type="button" onclick="qx()" value="取消" style=" width: 50px; height: 30px;   background-color:transparent; border:1px solid #EEF0F3; border-radius:7px;" />
		<script src="jquery/jquery-1.11.3.min.js"></script>
		<script>
			
			
			// let a= data[i].spAnswerTime=timestampToTime(data[i].spAnswerTime);
			//
					$.ajax({
						url: "http://localhost:8081/typePaper/answerTime?spId=1",
						type: 'post',
						dataType: "json",
						async: false,
						success: function(data) {
							$('#shijian').html('');
							for (var i = 0; i < data.length; i++) {
								
							 let sj=data[i].spAnswerTime;
							let sjj= setInterval("showtime()",1000);		 
								$('#shijian').append('<h7 id="shijian">'+sj+'</h7>')
								
							}		
						}
					})
					var a;
					//获取单选题
					$.ajax({
						url: "http://localhost:8081/typePaper/PaperFindById?typeId=1",
			
						type: 'post',
						dataType: "json",
						async: false,
						success: function(data) {
							$('#table').html('');
							// for(var i = 0;i<data.length;i++){
							// 	$('#table').append('<label style="margin-left: 1.6rem;">'+data[i].qbId+'<lable>'+'<label>&nbsp; &nbsp;&nbsp;&nbsp;'
							// 	+data[i].qbName+
							// 	'</label > <br />'+'<br /><label style="margin-left: 3rem;"><input type="radio" name="value" value="NO"> '
							// 	+data[i].qbOptions+
							// 	'</label> <br><br>')
							// }
							for (var i = 0; i < data.length; i++) {
								// 给data[i].qbOptions调用split(",")方法 让data[i].qbOptions里面的数据通过,分割 返回一个作用域 ss
								let ss = data[i].qbOptions.split(",");
								a = data[i].qbId;
								// 创建一个空的 str容器
								let str = "";
								// 遍历ss
								for (var s = 0; s < ss.length; s++) {
									// 把遍历出来的ss数据 返回给str容器
									str += '<input type="radio" id="qbid" class="advancedBespeakRadio" name="' + data[i].qbId + '" value="' + data[i].qbId + '"> ' + ss[s];
									
								}
								// console.log(str);
								//定义一个ying  把需要的数据拼接过来 (data[i].qbId)
								let ying = '<label style="margin-left: 1.6rem;">' + data[i].qbId + '<lable>' +
									'<label>&nbsp; &nbsp;&nbsp;&nbsp;' +
									data[i].qbName +
									'</label > <br />' + '<br /><label style="margin-left: 3rem;">' +
									str +
									'</label> <br><br>'
								//把数据拼接给页面0
								$('#table').append(ying)
								// $('#table').append('<label style="margin-left: 1.6rem;">'+data[i].qbId+'<lable>'+'<label>&nbsp; &nbsp;&nbsp;&nbsp;'
								// +data[i].qbName+
								// '</label > <br />'+'<br /><label style="margin-left: 3rem;"><input type="radio" name="value" value="NO"> '
								// +data[i].qbOptions+
								// '</label> <br><br>')
								// 
							}
						}
					})
					//多选题
					$.ajax({
						url: "http://localhost:8081/typePaper/PaperFindById?typeId=2",
			
						type: 'post',
						dataType: "json",
						async: false,
						success: function(data1) {
							$('#table1').html('');
			
							for (var i = 0; i < data1.length; i++) {
								// 给data[i].qbOptions调用split(",")方法 让data[i].qbOptions里面的数据通过,分割 返回一个作用域 ss
								let sss = data1[i].qbOptions.split(",");
								// console.log(ss);
								// 创建一个空的 str容器
								qbid = data1[i].qbId;
								let str = "";
								// 遍历ss
								for (var s = 0; s < sss.length; s++) {
									// 把遍历出来的ss数据 返回给str容器
									str += '<input type="checkbox" name="' + data1[i].qbId + '" value="' + data1[i].qbId + '"> ' + sss[s];
								
								}
								let ying ='<label id="qbId" style="margin-left: 1.6rem;">' + data1[i].qbId + '<lable>' + '&nbsp; &nbsp;' +
								 	data1[i].qbName +
								 	'<br /><br />' +
								 	'<label id="qbId1" style="margin-left: 3rem;" >' +
								 	str +
								 	'</label> <br><br>'
								$('#table1').append(ying)
								
								// $('#table1').append('<label style="margin-left: 1.6rem;">' + data1[i].qbId + '<lable>' + '&nbsp; &nbsp;' +
								// 	data1[i].qbName +
								// 	'<br /><br />' +
								// 	'<label style="margin-left: 3rem;" ><input name="Fruit" type="checkbox" value="" />' +
								// 	data1[i].qbOptions +
								// 	'</label> <br><br>')
							}
						}
					})
					var qbid1;
					//简答题
					$.ajax({
						url: "http://localhost:8081/typePaper/PaperFindById?typeId=3",
						
						type: 'post',
						dataType: "json",
						async: false,
						success: function(data2) {
							$('#table3').html('');
							for (var i = 0; i < data2.length; i++) {
								qbid1 = data2[i].qbId;
								$('#table3').append('<h4 style="margin-left: 1.5rem;">'+data2[i].qbId+'<h4>'+'<h4 style="margin-left: 2.7rem; margin-top: -1.1rem;">'+data2[i].qbName+'<h4>'+'<textarea class="t_area" style="width: 852%;">'+'</textarea>')
								
							}
						}
					})
			
			//获取上个页面拼接的参数
			var path =  window.location.search;
			//数组获取等号右边数
			var array = path.split("&");
			var ids = {};
			for (var i = 0; i < array.length; i++) {
				ids[i] = array[i].split("=")[1]
				console.log(array[i].split("=")[1])
			}
			var spName = decodeURI(ids[3]);
			function sub(){
				var flag =confirm("您确定提交吗?");
				if(flag){
					
					$.ajax({
						url: 'http://localhost:8081/studentPaper/getRedis',
						type: "post",
						dataType: "json",
						success: function(data) {
							//console.log(data);
							var item = data.data;
							for (var i = 0; i < item.length; i++) {
								var userId = item[i].userId;
								var spGradeId = item[i].userGradeId;
								var spClassesId = item[i].userClassesId;
							}
							var userId = userId;
							var spGradeId = spGradeId;
							var spClassesId = spClassesId;
							$.ajax({
								url: 'http://localhost:8081/studentPaper/addeStudentTestPaperpage',
								type: "post",
								dataType: "json",
								data:{
									spName:spName,
									spSubjectId:ids[0],
									spTypeId:ids[1],
									spUserId:userId,
									spGradeId:spGradeId,
									spClassesId:spClassesId
								},
								success: function(data) {								
									if (data == "200") {
										alert("提交成功");
										window.location.href = "learn-Testrecords.html"
									} else {
										alert("提交失败")
									}
								},
							})
						},
					})
					var advancedBespeakRadio = document.getElementsByClassName("advancedBespeakRadio").value;
					console.log(advancedBespeakRadio[1].innerText);
					$.ajax({
							url: 'http://localhost:8081/paper/selPaper?&paperStudentPaperId='+ids[2]+' ' ,
							type: "post",
							dataType: "json",
							success: function(data) {
								$.ajax({
									url: "http://localhost:8081/paper/updPaper",
									type: "post",
									data: {
										paperStudentPaperId:ids[2],
										paperQuestionBankId:paperQuestionBankId
									},
									dataType: "json",
									success: function(data) {
										
									},
								})
							},
						})
					
					
					
				}
				
			}
			function qx(){
				window.close();
			}
		</script>
	</body>
</html>
